package com.wanyang.config;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
@ConfigurationProperties(prefix = "secure.ignored")
public class IgnoreUrlsConfig {

    private List<String> urls = new ArrayList<>();

    public boolean isAllow(String requestUrl) {
        PathMatcher pathMatcher = new AntPathMatcher();
        for (String path : urls) {
            if(pathMatcher.match(path, requestUrl)){
                return true;
            }

        }
        return false;
    }
}
